package xin.clips.system.service.impl;

import java.util.List;
import xin.clips.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import xin.clips.common.core.text.Convert;
import xin.clips.system.domain.gy.GyMachineParam;
import xin.clips.system.dto.MachineParamDTO;
import xin.clips.system.mapper.gy.GyMachineParamMapper;
import xin.clips.system.service.gy.IGyMachineParamService;

/**
 * 机床配置Service业务层处理
 *
 * @author clips
 * @date 2023-03-13
 */
@Service
public class GyMachineParamServiceImpl implements IGyMachineParamService
{
    @Autowired
    private GyMachineParamMapper gyMachineParamMapper;

    /**
     * 查询机床配置
     *
     * @param machineId 机床配置主键
     * @return 机床配置
     */
    @Override
    public GyMachineParam selectGyMachineParamByMachineId(Long machineId)
    {
        return gyMachineParamMapper.selectGyMachineParamByMachineId(machineId);
    }

    /**
     * 查询机床配置列表
     *
     * @param gyMachineParam 机床配置
     * @return 机床配置
     */
    @Override
    public List<GyMachineParam> selectGyMachineParamList(GyMachineParam gyMachineParam)
    {
        return gyMachineParamMapper.selectGyMachineParamList(gyMachineParam);
    }

    /**
     * 新增机床配置
     *
     * @param gyMachineParam 机床配置
     * @return 结果
     */
    @Override
    public int insertGyMachineParam(GyMachineParam gyMachineParam)
    {
        gyMachineParam.setCreateTime(DateUtils.getNowDate());
        return gyMachineParamMapper.insertGyMachineParam(gyMachineParam);
    }

    /**
     * 修改机床配置
     *
     * @param gyMachineParam 机床配置
     * @return 结果
     */
    @Override
    public int updateGyMachineParam(GyMachineParam gyMachineParam)
    {
        gyMachineParam.setUpdateTime(DateUtils.getNowDate());
        return gyMachineParamMapper.updateGyMachineParam(gyMachineParam);
    }

    /**
     * 批量删除机床配置
     *
     * @param machineIds 需要删除的机床配置主键
     * @return 结果
     */
    @Override
    public int deleteGyMachineParamByMachineIds(String machineIds)
    {
        return gyMachineParamMapper.deleteGyMachineParamByMachineIds(Convert.toStrArray(machineIds));
    }

    /**
     * 删除机床配置信息
     *
     * @param machineId 机床配置主键
     * @return 结果
     */
    @Override
    public int deleteGyMachineParamByMachineId(Long machineId)
    {
        return gyMachineParamMapper.deleteGyMachineParamByMachineId(machineId);
    }

    /**
     * 查询机床配置根据设备ID
     *
     * @param deviceId 机床配置主键
     * @return 机床配置
     */
    @Override
    public GyMachineParam selectGyMachineParamByDeviceId(Long deviceId){
        return gyMachineParamMapper.selectGyMachineParamByDeviceId(deviceId);
    }

    /**
     * 大屏-查询机床配置根据设备ID
     *
     * @param deviceId 机床配置主键
     * @return 机床配置
     */
    public MachineParamDTO selectDpGyMachineParamByDeviceId(Long deviceId){
        return gyMachineParamMapper.selectDpGyMachineParamByDeviceId(deviceId);
    }
}
